<?php

/*
 * ************************************************* 
 * Created on :2012-5-17 22:57:02
 * Encoding   :UTF-8
 * Description:
 * 
 * @Author @lqs <soso2501@gmail.com>
 * @WAP_WEIBO (C)1996-2099 SINA Inc. 
 * ************************************************
 */

class Place {

    static $manage_table = "place_manager";
    static $table = "place";

    public static function allnames() {
        $r = DB::LimitQuery(self::$table, array("select" => "name"));
        $return = array();
        foreach ($r as $v)
            $return[] = $v['name'];
        return $return;
    }

    public static function get($name) {
        return DB::LimitQuery(self::$table, array("condition" => array("name" => $name), "one" => true));
    }

    public static function mod($name, $describe, $show = "Y") {
        if (empty($name))
            return false;
        $r = DB::GetTableRow(self::$table, array("name" => $name));
        $data = array("name" => $name, "describe" => $describe, "show" => $show);
        if (empty($r)) {
            return DB::Insert(self::$table, $data);
        } else {
            if ($r['show'] == $show && $r['describe'] == $describe)
                return true;
            else
                return DB::Update(self::$table, $name, $data, "name");
        }
    }

}

/* End of file Place */


